<!--#include file="inc/conn.asp" -->
<%CheckAdmin()%>
<!--#include file="inc/Function.asp" -->
<%
strtitle=ServerName&"-公告管理"
Action=Request("Action")
action_ok=Request("action_ok")
ID=CheckStr(Request("ID"))


Select Case Action
	Case "Save"
		Call Save()
	Case Else
		Call Main()
End Select 

Sub Main()


if ID<>"" then 

	If Not isnumeric(id) Then 
		response.write "id错误"
		response.end
	End If


	Sql="Select * FROM Web_News Where ID="&ID
	Set Rs=conn.Execute(Sql)
	ID=Rs("ID")
	title=Rs("title")
	NewsContent=Rs("NewsContent")
	Author=Rs("Author")
	NewsClass=Rs("NewsClass")
	topid=Rs("topid")
	NewsDate=Rs("NewsDate")



	showstr="修改"
	Else
	showstr="添加"
	end if 

	'response.write "<br>ID="&ID
	'response.write "<br>topid="&Rs("topid")
	'response.write "<br>NewsDate="&NewsDate
	'response.end

	Set Rs=Nothing

		 strtitle=CharName16&"-信息修改"
		Call  head(strtitle)
		Call  LeftMenu


%>
<script src="editor/edit.js" type="text/javascript"></script>



			

  <div class="page-content" <%=bstyle%>>
    <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
         <div class="layui-form-item">
           

 <form  class="layui-form layui-form-pane">

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>表单集合演示</legend>
</fieldset>
 
  <div class="layui-form-item">
    <label class="layui-form-label">单行输入框</label>
    <div class="layui-input-block">
      <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">验证必填项</label>
    <div class="layui-input-block">
      <input type="text" name="username" lay-verify="required" lay-reqText="用户名是必填项，岂能为空？" placeholder="请输入" autocomplete="off" class="layui-input">
    </div>
  </div>
  
    <div class="layui-inline">
      <label class="layui-form-label">验证日期</label>
      <div class="layui-input-inline">
        <input type="text" name="date" id="date" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
      </div>
    </div>
   







                <div class="layui-form-item">
					<label for="CharID" class="layui-form-label">
                        <span class="x-red"></span>文章标题:</label>
                    <div class="layui-input-inline">
                        <input type="text" name="CharID" required="" lay-verify="required" autocomplete="off" class="layui-input" value="<%=title%>" style="width:358px">
                        <input type="hidden" name="JID" value="<%=JID%>">
                        <input type="hidden" name="StrUserID"  value="<%=StrUserID%>">
                    </div>

        <div class="layui-row">


                    <label for="CharName16" class="layui-form-label">
                        <span class="x-red"></span>发布时间:</label>
                    <div class="layui-input-inline">
                        <input type="text" name="CharName16" required="" lay-verify="required" autocomplete="off" class="layui-input" value="<%=NewsDate%>" style="width:358px">
					 </div> 
					 <a href="javascript:" onClick="document.myform.newsdate.value='<%=now()%>'">插入当前时间</a>
</div> 

</div> 

        <div class="layui-row">

						<input type="text" name="topid" style="WIDTH: 30px" class="editbox" value="<%=topid%>">

						<input name="GoUrl" type="hidden" id="GoUrl" value="<%=Url%>">
						<input name="ID" type="hidden" id="ID" value="<%=ID%>">

						  <div class="layui-form-item">
    <label class="layui-form-label">单选框</label>
    <div class="layui-input-block">
      <input type="radio" name="sex" value="男" title="男" checked>
      <input type="radio" name="sex" value="女" title="女">
      <input type="radio" name="sex" value="禁" title="禁用" disabled>
    </div>
  </div>


						<input type="radio" id="radio" <%if NewsClass=1 then response.write "value=""1"" checked=""checked"""%> >网站公告
						<input type="radio" id="radio" <%if NewsClass=0 then response.write "value=""0"" checked=""checked"""%>>游戏攻略
</div> 
                                           




<textarea id="editor_id" name="content" style="width:700px;height:300px;"><%=NewsContent%></textarea>


<input type="submit" value="<%=showstr%>信息" name=submit class="btn btn-primary">

            </form>



        </div>
    </div>
    </div>
    </div>

<%	
	set conn=Nothing
end Sub

Sub Save()



    Title=CheckStr(Request.Form("Title"))
	NewsContent=Request("Content")
	NewsDate=Request.Form("NewsDate")
	Author=Checkstr(Request.Form("Author"))
	noticle=Request.Form("noticle")
	NewsClass=Request.Form("NewsClass")
	topid=Request.Form("topid")


    If Title="" Then strMsg=strMsg&"<Li>标题不能为空。"
	If NewsContent="" Then strMsg=strMsg&"<Li>内容不能为空。"
	If Not isDate(NewsDate) Then NewsDate=date() else 
    If Author="" Then Author="不详"
	If NewsClass<>1  Then NewsClass=0
	If topid="" Or IsNumeric(topid)=0 Then topid=1

	If strMsg<>"" Then 
	    response.write strMsg
		response.end
	Else
	ID=CheckStr(Request("ID"))
     Set Rs=Server.Createobject("Adodb.Recordset")


	If ID<>"" Then 
		Sql="Select * From Web_news Where ID="&ID
        Rs.Open Sql,conn,1,3
		showstr="修改"
	Else
        Sql="Select * FROM Web_news"
        Rs.Open Sql,conn,1,3
        Rs.Addnew
		showstr="添加"
	End If 


        Rs("Title")=Title
        Rs("NewsContent")=NewsContent
        Rs("Author")=Author
		Rs("NewsDate")=NewsDate
	    Rs("NewsClass")=NewsClass
	    Rs("topid")=topid

        Rs.Update
        Rs.Close
        Set Rs=Nothing
		response.write "<script language=javascript>alert('"&showstr&"成功!');location.href='News.asp'</script>"
		response.end

	End If 
End Sub
%>
<br>
